package com.business_clean.ui.adapter.attendance;

import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.business_clean.R;
import com.business_clean.app.weight.CustomAvatarView;
import com.business_clean.data.mode.attendance.AttendanceListEntity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class DateAttendanceMonthAdapter extends BaseQuickAdapter<AttendanceListEntity, BaseViewHolder> {

    public DateAttendanceMonthAdapter() {
        super(R.layout.item_date_attendance);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, AttendanceListEntity item) {
        holder.setText(R.id.tv_item_roster_name, item.getUser_name());
        TextView tvDesc = holder.getView(R.id.tv_item_roster_phone);

        CustomAvatarView avatarView = holder.getView(R.id.iv_item_roster_avatar);
        avatarView.setAvatar(item.getAvatar(), item.getUser_name());

        holder.getView(R.id.iv_item_roster_edit).setVisibility(View.GONE);

        //在这里呀哦区分身份 如果是保洁员，那么就显示基本信息
        StringBuilder stringBuilder = new StringBuilder();
        if (!TextUtils.isEmpty(item.getSex_name())) {
            stringBuilder.append(item.getSex_name());
        }
        if (!TextUtils.isEmpty(item.getJob_name())) {
            stringBuilder.append(" / ").append(item.getJob_name());
        }
        if (!TextUtils.isEmpty(item.getWork_start_time())) {
            stringBuilder.append(" / ").append(item.getWork_start_time()).append("入职");
        }
        if (!TextUtils.isEmpty(item.getWork_end_time())) {
            stringBuilder.append(" / ").append(item.getWork_end_time()).append("离职");
        }
        tvDesc.setText(stringBuilder.toString());
        //状态
        TextView tvAttendanceDays = holder.getView(R.id.tv_item_attendance_days);
        tvAttendanceDays.setText("出勤天数" + item.getActual_attendance_days() + "/" + item.getAttendance_days());

        //应出勤
        TextView tvAttendanceAbsenteeism = holder.getView(R.id.tv_item_attendance_absenteeism);

        if ("1".equals(item.getIs_absenteeism())) {
            tvAttendanceAbsenteeism.setTextColor(Color.parseColor("#FF4040"));
            tvAttendanceAbsenteeism.setBackgroundColor(Color.parseColor("#FFF1F0"));
        } else {
            tvAttendanceAbsenteeism.setTextColor(Color.parseColor("#B0B1B8"));
            tvAttendanceAbsenteeism.setBackgroundColor(Color.parseColor("#F5F6F9"));
        }

        //缺卡
        TextView tvAttendanceMissCard = holder.getView(R.id.tv_item_attendance_miss_card);

        if ("1".equals(item.getIs_qk())) {
            tvAttendanceMissCard.setTextColor(Color.parseColor("#FE6B03"));
            tvAttendanceMissCard.setBackgroundColor(Color.parseColor("#10FF801A"));
        } else {
            tvAttendanceMissCard.setTextColor(Color.parseColor("#B0B1B8"));
            tvAttendanceMissCard.setBackgroundColor(Color.parseColor("#F5F6F9"));
        }


        //加班
        TextView tvAttendanceOverTime = holder.getView(R.id.tv_item_attendance_overtime);

        if ("1".equals(item.getIs_overtime())) {
            tvAttendanceOverTime.setTextColor(Color.parseColor("#1890FF"));
            tvAttendanceOverTime.setBackgroundColor(Color.parseColor("#101890FF"));
        } else {
            tvAttendanceOverTime.setTextColor(Color.parseColor("#B0B1B8"));
            tvAttendanceOverTime.setBackgroundColor(Color.parseColor("#F5F6F9"));
        }


        //休息
        TextView tvAttendanceRest = holder.getView(R.id.tv_item_attendance_rest);
        tvAttendanceRest.setVisibility(View.GONE);
//        if ("1".equals(item.getIs_rest())) {
//            tvAttendanceRest.setTextColor(Color.parseColor("#F5F6F9"));
//            tvAttendanceRest.setBackgroundColor(Color.parseColor("#8D8E99"));
//        } else {
//            tvAttendanceRest.setTextColor(Color.parseColor("#B0B1B8"));
//            tvAttendanceRest.setBackgroundColor(Color.parseColor("#F5F6F9"));
//        }

        //休假

        TextView tvAttendanceHoliday = holder.getView(R.id.tv_item_attendance_holiday);

        if ("1".equals(item.getIs_holiday())) {
            tvAttendanceHoliday.setTextColor(Color.parseColor("#A671CF"));
            tvAttendanceHoliday.setBackgroundColor(Color.parseColor("#15A671CF"));
        } else {
            tvAttendanceHoliday.setTextColor(Color.parseColor("#B0B1B8"));
            tvAttendanceHoliday.setBackgroundColor(Color.parseColor("#F5F6F9"));
        }

    }
}
